﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Framework.Message.SMS.SGIP.Commands
{
    public class PingCommand : Command
    {
        private ReportCommand command;

        public override SGIPCommandType CommandType
        {
            get { return SGIPCommandType.Bind; }
        }

        public override uint BodyLength
        {
            get { return 1 + 16 + 16 + 8; }
        }

        public PingCommand()
        {

        }

        public PingCommand(byte[] bytes)
            : base(bytes)
        {
        }

        public PingCommand(byte[] bytes, int startIndex)
            : base(bytes, startIndex)
        {
        }

        public PingCommand(CommandSequence sequence)
            : base(sequence)
        {
            command = new ReportCommand(sequence);
            command.SubmitSequenceNumber = new CommandSequence(Header.SequenceNumber.SrcID.ToString(), DateTime.Now, 0);
            command.ReportType = ReportType.Submit;
            command.State = ReportState.Success;
            command.UserNumber = "";
        }

        protected override void BytesTo(byte[] bytes, int startIndex)
        {
            command = new ReportCommand(bytes, startIndex);
            command.SubmitSequenceNumber = new CommandSequence(Header.SequenceNumber.SrcID.ToString(), DateTime.Now, 0);
            command.ReportType = ReportType.Submit;
            command.State = ReportState.Success;
            command.UserNumber = "";
        }

        public override byte[] ToBytes()
        {
            return command.ToBytes();
        }
    }
}
